home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 41 / 041.d81 / snag source (.txt) < prev    next >
Encoding:
Commodore BASIC  |  1987-01-01  |  20.1 KB  |  779 lines

  1. 1000 sys700:.opt oo
  2. 1010 *=$c000
  3. 1020 ;
  4. 1030 ;********************************
  5. 1040 ;*                              *
  6. 1050 ;*           snag 1.0           *
  7. 1060 ;*                              *
  8. 1070 ;* copyright 1987  by nick peck *
  9. 1080 ;*                              *
  10. 1090 ;********************************
  11. 1100 ;
  12. 1110 nmioff =$fec1 ;restore is off here
  13. 1120 stuff  =$f000 ;mem. for snag stack
  14. 1130 string =$ab1e ;display a string
  15. 1140 getin  =$ffe4 ;get a keyboard byte
  16. 1150 chrout =$ffd2 ;output a byte
  17. 1160 chrin  =$ffcf ;64's input routine
  18. 1170 plot   =$fff0 ;plot 64's cursor
  19. 1180 close  =$ffc3 ;close a file
  20. 1190 clall  =$ffe7 ;close all files
  21. 1200 open   =$ffc0 ;open a file
  22. 1210 setnam =$ffbd ;set file name
  23. 1220 setlfs =$ffba ;set file status
  24. 1230 talk   =$ffb4 ;make device talk
  25. 1240 tksa   =$ff96 ;talk second address
  26. 1250 chkout =$ffc9 ;open output channel
  27. 1260 untlk  =$ffab ;make device untalk
  28. 1270 acptr  =$ffa5 ;serial port get
  29. 1280 cursco =$0286 ;64's cursor color
  30. 1290 scnlin =$0748 ;start of menu
  31. 1300 txtlin =$0770 ;start of text line
  32. 1310 collin =$db48 ;menu color memory
  33. 1320 a      =$02 ;temps used everywhere
  34. 1330 b      =$03 ;     ''      ''
  35. 1340 xtemp  =$04 ;     ''      ''
  36. 1350 ytemp  =$05 ;     ''      ''
  37. 1360 blockx =$fd ;position of block
  38. 1370 blocky =$fe ;     ''      ''
  39. 1380 xpos   =$fb ;position of cursor
  40. 1390 ypos   =$fc ;     ''      ''
  41. 1400 lowpnt =$06 ;low-high used in plot
  42. 1410 highpt =$07 ;     ''      ''
  43. 1420 collow =$22 ;used to get old color
  44. 1430 colhii =$23 ;     ''      ''
  45. 1440 oldcol =$24 ;flag- use old color
  46. 1450 addmov =$25 ;flag- right or down
  47. 1460 xptemp =$4b ;temp for make block
  48. 1470 yptemp =$4c ;     ''      ''
  49. 1480 xbtemp =$4d ;     ''      ''
  50. 1490 ybtemp =$4e ;     ''      ''
  51. 1500 flpplt =$4f ;flag- plot y,x *(x,y)
  52. 1510 output =$50 ;flag- output unblock
  53. 1520 lastch =$51 ;temp for unblock
  54. 1530 choice =$52 ;append choice (y/n)
  55. 1540 curcol =$53 ;current snag color
  56. 1550 qtmode =$d4 ;64 quote mode on/off
  57. 1560 ;
  58. 1570 ;the following code copies the
  59. 1580 ;stack and zero page so that snag
  60. 1590 ;has it's own stack and zero page
  61. 1600 ;when entered via the hardware irq
  62. 1610 ;
  63. 1620 intstr lda #"n"      ;start append
  64. 1630        sta choice    ;choice as 'n
  65. 1640        lda #"/"
  66. 1650        sta fname     ;start file
  67. 1660        lda #","      ;name as '/'
  68. 1670        sta fname+1
  69. 1680        sei
  70. 1690        lda #>rthere   ;set return
  71. 1700        pha            ;address for
  72. 1710        lda #<rthere-1 ;flip stack
  73. 1720        pha            ;routine.
  74. 1730        tsx            ;save stack
  75. 1740        stx stktmp     ;pointer
  76. 1750        lda #0
  77. 1760        sta $fb        ;copy first
  78. 1770        sta $fc        ;4 blocks of
  79. 1780        lda #<stuff    ;memory
  80. 1790        sta $fd
  81. 1800        lda #>stuff
  82. 1810        sta $fe
  83. 1820        ldx #4
  84. 1830        ldy #2
  85. 1840 mrtoit lda ($fb),y
  86. 1850        sta ($fd),y
  87. 1860        iny
  88. 1870        bne mrtoit
  89. 1880        inc $fc
  90. 1890        inc $fe
  91. 1900        dex
  92. 1910        bne mrtoit
  93. 1920        lda #<nmioff  ;snag vectors
  94. 1930        sta $0318     ;snag restore
  95. 1940        lda #>nmioff  ;is disabled
  96. 1950        sta $0319
  97. 1960        lda #<extsng  ;brk vector
  98. 1970        sta $0316     ;is used to
  99. 1980        lda #>extsng  ;exit snag
  100. 1990        sta $0317
  101. 2000        lda #>start  ;new pch
  102. 2010        pha
  103. 2020        lda #<start  ;new pcl
  104. 2030        pha
  105. 2040        lda #0       ;status
  106. 2050        pha
  107. 2060        pha          ;.a
  108. 2070        pha          ;.x
  109. 2080        pha          ;.y
  110. 2090        lda #>rthre2   ;set return
  111. 2100        pha            ;address for
  112. 2110        lda #<rthre2-1 ;next flip
  113. 2120        pha            ;stack call
  114. 2130        jmp flipmm   ;flip stacks
  115. 2140 rthere lda #<baserr ;change basics
  116. 2150        sta $0300    ;error message
  117. 2160        lda #>baserr ;vector to
  118. 2170        sta $0301    ;reset irq
  119. 2180        cli
  120. 2190        lda #96      ;put an rts
  121. 2200        sta intstr   ;in first byte
  122. 2210        rts
  123. 2220 ;
  124. 2230 ;every time basic prints an error
  125. 2240 ;or a 'ready' the irq vector is
  126. 2250 ;set to snag
  127. 2260 ;
  128. 2270 baserr sei
  129. 2280        ldy #<(NULL)ther ;new irq that
  130. 2290        sty $0314    ;looks for a
  131. 2300        ldy #>(NULL)ther ;ctrl-f3
  132. 2310        sty $0315
  133. 2320        cli
  134. 2330        jmp $e38b
  135. 2340 ;
  136. 2350 ;the irq comes here to look for
  137. 2360 ;a ctrl-f3
  138. 2370 ;
  139. 2380 (NULL)ther lda $c5      ;look for f3
  140. 2390        cmp #5
  141. 2400        beq yesf3
  142. 2410 outirq jmp $ea31
  143. 2420 yesf3  lda $028d    ;look for ctrl
  144. 2430        cmp #4
  145. 2440        bne outirq
  146. 2450        lda #>retext
  147. 2460        pha
  148. 2470        lda #<retext-1
  149. 2480        pha
  150. 2490        jmp flipmm   ;flip stacks
  151. 2500 rthre2 jmp $ea31
  152. 2510 ;
  153. 2520 extsng lda #>rthre2
  154. 2530        pha
  155. 2540        lda #<rthre2-1
  156. 2550        pha
  157. 2560        jmp flipmm   ;flip stacks
  158. 2570 retext jmp $ea31
  159. 2580 ;
  160. 2590 ;this routine flips the stack
  161. 2600 ;memory with a modified stack
  162. 2610 ;in memory without using
  163. 2620 ;zero page
  164. 2630 ;
  165. 2640 flipmm lda #<stuff
  166. 2650        sta top+1    ;source low
  167. 2660        sta stuff2+1
  168. 2670        lda #>stuff
  169. 2680        sta top+2    ;source high
  170. 2690        sta stuff2+2
  171. 2700        lda #0
  172. 2710        sta stuff1+1 ;target low
  173. 2720        sta stuff3+1
  174. 2730        sta stuff1+2 ;target high
  175. 2740        sta stuff3+2
  176. 2750        ldy #4
  177. 2760        ldx #2
  178. 2770 toplop lda #52      ;off basic
  179. 2780        sta $01
  180. 2790 top    lda $ffff,x  ;source
  181. 2800        sta tmpbyt
  182. 2810        lda #55      ;on basic
  183. 2820        sta $01
  184. 2830 stuff1 lda $ffff,x  ;target
  185. 2840 stuff2 sta $ffff,x  ;source
  186. 2850        lda tmpbyt
  187. 2860 stuff3 sta $ffff,x  ;target
  188. 2870        inx
  189. 2880        bne toplop
  190. 2890        inc top+2
  191. 2900        inc stuff1+2
  192. 2910        inc stuff2+2
  193. 2920        inc stuff3+2
  194. 2930        dey
  195. 2940        bne toplop
  196. 2950        lda stktmp   ;flip stack
  197. 2960        tsx          ;pointers
  198. 2970        stx stktmp
  199. 2980        tax
  200. 2990        txs
  201. 3000        rts
  202. 3010 ;
  203. 3020 start  ldy #0       ;actual start
  204. 3030        sty xpos     ;of snag code
  205. 3040        lda #216
  206. 3050        sta ypos
  207. 3060        lda #<color  ;make a copy
  208. 3070        sta blockx   ;of screen
  209. 3080        lda #>color  ;color
  210. 3090        sta blocky
  211. 3100        ldx #4
  212. 3110 trans  lda (xpos),y
  213. 3120        sta (blockx),y
  214. 3130        iny
  215. 3140        bne trans
  216. 3150        inc ypos
  217. 3160        inc blocky
  218. 3170        dex
  219. 3180        bne trans    ;set snag cur-
  220. 3190        lda 53281    ;sor color
  221. 3200        and #15      ;according to
  222. 3210        tax          ;table
  223. 3220        lda colors,x
  224. 3230        sta curcol
  225. 3240        ldx #255     ;disable block
  226. 3250        stx blockx   ;with two ff's
  227. 3260        stx blocky
  228. 3270        inx
  229. 3280        stx oldcol ;1 = old color
  230. 3290        stx addmov ;1 = add x or y
  231. 3300        stx flpplt ;1 = y,x not x,y
  232. 3310        stx output ;1 = disk/printr
  233. 3320        stx xpos   ;cursor x and y
  234. 3330        stx ypos
  235. 3340        txa
  236. 3350        tay        ;plot initial
  237. 3360        jsr revers ;cursor
  238. 3370 getmor jsr getin
  239. 3380        beq getmor
  240. 3390        cmp #"[133]"   ;is it an f1
  241. 3400        bne nostop
  242. 3410        jsr unblck ;yes, shut off
  243. 3420        ldx xpos   ;block, erase
  244. 3430        ldy ypos   ;cursor and exit
  245. 3440        inc oldcol ;according to
  246. 3450        jsr revers ;the brk vector
  247. 3460        brk
  248. 3470        nop:nop:nop ;pc returns
  249. 3480        jmp start   ;here
  250. 3490 nostop cmp #""    ;cursor right
  251. 3500        bne notrit
  252. 3510        ldx xpos
  253. 3520        cpx #39
  254. 3530        beq notrit
  255. 3540        inc addmov  ;set add flag
  256. 3550        jsr xblock  ;move right
  257. 3560        dec addmov  ;unset add flag
  258. 3570 notrit cmp #"[157]"    ;cursor left
  259. 3580        bne notlft
  260. 3590        ldx xpos
  261. 3600        beq notlft
  262. 3610        inc oldcol  ;set color flag
  263. 3620        jsr xblock  ;move left
  264. 3630        dec oldcol  ;unset col flag
  265. 3640 notlft cmp #""    ;cursor down
  266. 3650        bne notdwn
  267. 3660        ldx ypos
  268. 3670        cpx #24
  269. 3680        beq notdwn
  270. 3690        inc addmov  ;set add flag
  271. 3700        jsr yblock  ;move down
  272. 3710        dec addmov  ;unset add flag
  273. 3720 notdwn cmp #"[145]"    ;cursor up
  274. 3730        bne notup
  275. 3740        ldx ypos
  276. 3750        beq notup
  277. 3760        inc oldcol  ;set color flag
  278. 3770        jsr yblock  ;move up
  279. 3780        dec oldcol  ;unset col flag
  280. 3790 notup  cmp #"[146]"    ;reverse off
  281. 3800        bne notunb
  282. 3810        jsr unblck  ;shut off block
  283. 3820 notunb cmp #""    ;reverse on
  284. 3830        bne nosblk
  285. 3840        jsr onblck  ;turn on block
  286. 3850 nosblk cmp #13     ;a return
  287. 3860        bne notret
  288. 3870        jmp newmen  ;(NULL) to new menu
  289. 3880 notret jmp getmor
  290. 3890        jmp getmor  ;3 extra bytes
  291. 3900        rts         ;for expansion
  292. 3910 ;
  293. 3920 newmen jsr plines  ;put lines on
  294. 3930 newmn2 lda curcol  ;set cursor
  295. 3940        sta cursco  ;color
  296. 3950        lda #<menu1 ;display snag
  297. 3960        ldy #>menu1 ;menu options
  298. 3970        jsr string
  299. 3980 getnew jsr getin   ;get a key
  300. 3990        beq getnew
  301. 4000        cmp #"[133]"    ;is it an f1
  302. 4010        bne notesc  ;no, move on
  303. 4020        jsr levnew  ;yes, return
  304. 4030        jmp getmor  ;screen and (NULL)
  305. 4040 notesc cmp #"p"    ;is key printer
  306. 4050        bne notpnt  ;no, move on
  307. 4060        jsr opnpnt  ;open printer
  308. 4070        lda #13     ;print a cr
  309. 4080        jsr chrout
  310. 4090        jsr clsfil  ;close printer
  311. 4100        lda $90    ;is printer on
  312. 4110        beq (NULL)ahed ;yes, move on
  313. 4120        jmp shoerr ;no, show error
  314. 4130 (NULL)ahed jsr opnpnt ;re-open printer
  315. 4140        jmp proce2 ;print block
  316. 4150 opnpnt ldy #$ff   ;default
  317. 4160        lda #%00000010
  318. 4170        bit 53272   ;check up case
  319. 4180        beq upcase
  320. 4190        ldy #7     ;no, print lower
  321. 4200 upcase lda #32    ;file number
  322. 4210        ldx #4     ;device number
  323. 4220        jsr setlfs ;set up file #32
  324. 4230        lda #0     ;set nill name
  325. 4240        jsr setnam
  326. 4250        jsr levnew ;erase new menu
  327. 4260        jsr open   ;open file #32
  328. 4270        ldx #32    ;make file #32
  329. 4280        jsr chkout ;an output file
  330. 4290        rts
  331. 4300 notpnt cmp #"f"   ;is key a file
  332. 4310        bne getnew ;no, (NULL) get key
  333. 4320        jsr space  ;clear space
  334. 4330        lda #<menu2 ;ask for
  335. 4340        ldy #>menu2 ;file name
  336. 4350        jsr string
  337. 4360        ldx #0
  338. 4370 mornam lda fname,x ;print last
  339. 4380        cmp #","    ;name until a
  340. 4390        beq notnam  ;comma (,) is
  341. 4400        jsr chrout  ;hit
  342. 4410        inx
  343. 4420        bne mornam
  344. 4430 notnam ldx #22     ;position
  345. 4440        ldy #20     ;cursor at
  346. 4450        clc         ;start of input
  347. 4460        jsr plot
  348. 4470        inc qtmode  ;quote mode on
  349. 4480        ldy #0
  350. 4490 readit jsr chrin   ;kernal input
  351. 4500        cmp #13
  352. 4510        beq endinp
  353. 4520        sta fname,y ;store input
  354. 4530        iny
  355. 4540        bne readit
  356. 4550 endinp lda #","      ;tack on ,s,
  357. 4560        sta fname,y   ;leaving the
  358. 4570        lda #"s"      ;last byte to
  359. 4580        sta fname+1,y ;be choosen
  360. 4590        lda #","      ;later
  361. 4600        sta fname+2,y
  362. 4610        sty a
  363. 4620        jsr space
  364. 4630        lda #<menu3  ;ask for an
  365. 4640        ldy #>menu3  ;append
  366. 4650        jsr string
  367. 4660        lda choice   ;print last
  368. 4670        jsr chrout   ;choice (y =
  369. 4680        lda #"[157]"     ;append, n =
  370. 4690        jsr chrout   ;write)
  371. 4700        inc qtmode   ;quote mode on
  372. 4710        jsr chrin    ;kernal input
  373. 4720        tay
  374. 4730        sty choice   ;save response
  375. 4740 untend jsr chrin    ;empty input
  376. 4750        cmp #13      ;buffer
  377. 4760        bne untend
  378. 4770        ldx choice
  379. 4780        lda #"w"     ;n = w(rite)
  380. 4790        ldy a
  381. 4800        cpx #"y"
  382. 4810        bne notapn
  383. 4820        lda #"a"     ;y = a(ppend)
  384. 4830 notapn sta fname+3,y
  385. 4840        tya
  386. 4850        clc          ;adjust length
  387. 4860        adc #4       ;of file name
  388. 4870        ldx #<fname
  389. 4880        ldy #>fname
  390. 4890        jsr setnam   ;kernal setnam
  391. 4900        lda #32
  392. 4910        ldx #8
  393. 4920        ldy #2
  394. 4930        jsr setlfs
  395. 4940        jsr levnew  ;erase new menu
  396. 4950        lda #8
  397. 4960        ldx #0
  398. 4970        stx $90
  399. 4980        jsr talk    ;make disk talk
  400. 4990        jsr untlk   ;to see if it
  401. 5000        ldx $90     ;is turned on
  402. 5010        beq nodker  ;on, move on
  403. 5020        jmp shoerr  ;off,show error
  404. 5030 nodker jsr open
  405. 5040        lda #8       ;check for a
  406. 5050        sta $ba      ;disk error
  407. 5060        jsr talk     ;after opening
  408. 5070        lda #$6f
  409. 5080        jsr tksa
  410. 5090        ldy #0
  411. 5100 morerr jsr acptr
  412. 5110        sta errbuf,y ;save disk
  413. 5120        iny          ;message
  414. 5130        cmp #13
  415. 5140        bne morerr
  416. 5150        jsr untlk
  417. 5160        lda #0
  418. 5170        sta errbuf,y ;end with 0
  419. 5180        lda errbuf   ;was there an
  420. 5190        cmp #"0"     ;error
  421. 5200        beq proced
  422. 5210        jsr plines   ;yes, display
  423. 5220        lda #<mesbuf ;disk error
  424. 5230        ldy #>mesbuf ;message
  425. 5240        jsr string
  426. 5250        jsr clsfil   ;close file
  427. 5260        jmp waitit   ;exit new menu
  428. 5270 proced ldx #32
  429. 5280        jsr chkout
  430. 5290 ;
  431. 5300 ;the printer also uses the
  432. 5310 ;following code to output its
  433. 5320 ;block
  434. 5330 ;
  435. 5340 proce2 inc output ;set output flag
  436. 5350        jsr unblck ;output block
  437. 5360        dec output ;unset output.
  438. 5370        lda $ba    ;check device
  439. 5380        cmp #4     ;printer
  440. 5390        bne noprnt ;no, move on
  441. 5400        lda #13    ;yes, do a cr
  442. 5410        jsr chrout
  443. 5420 noprnt jsr clsfil ;close file
  444. 5430        jmp getmor ;(NULL) to main menu
  445. 5440 ;
  446. 5450 clsfil lda #32    ;close file #32
  447. 5460        jsr close
  448. 5470        jmp clall
  449. 5480 ;
  450. 5490 shoerr jsr plines ;put lines on
  451. 5500        ldx #22
  452. 5510        ldy #8
  453. 5520        clc
  454. 5530        jsr plot
  455. 5540        lda #<menu4 ;print output
  456. 5550        ldy #>menu4 ;device is off
  457. 5560        jsr string
  458. 5570 waitit jsr getin   ;wait for a key
  459. 5580        beq waitit
  460. 5590        jsr space   ;erase lines
  461. 5600        jmp newmn2  ;output menu
  462. 5610 ;
  463. 5620 levnew ldx #119    ;put old screen
  464. 5630 lines2 lda menu,x  ;back
  465. 5640        sta scnlin,x
  466. 5650        lda menu+120,x
  467. 5660        sta collin,x
  468. 5670        dex
  469. 5680        bpl lines2
  470. 5690        rts
  471. 5700 ;
  472. 5710 plines ldx #119
  473. 5720 lines  lda scnlin,x ;save three
  474. 5730        sta menu,x   ;lines of the
  475. 5740        lda collin,x ;screen in mem
  476. 5750        sta menu+120,x
  477. 5760        lda #64     ;use a line
  478. 5770        sta scnlin,x
  479. 5780        lda curcol  ;get color
  480. 5790        sta collin,x
  481. 5800        dex
  482. 5810        bpl lines
  483. 5820 space  ldx #39     ;clear the line
  484. 5830        lda #32     ;used for text
  485. 5840 zapscn sta txtlin,x
  486. 5850        dex
  487. 5860        bpl zapscn
  488. 5870        ldx #22
  489. 5880        ldy #0      ;position
  490. 5890        clc         ;cursor and
  491. 5900        jmp plot    ;return
  492. 5910 ;
  493. 5920 ;converts x , y into low , high
  494. 5930 ;
  495. 5940 makexy lda flpplt ;is plot normal
  496. 5950        beq normal
  497. 5960        stx ytemp  ;flipped y,x
  498. 5970        sty xtemp
  499. 5980        jmp theplt
  500. 5990 normal stx xtemp   ;normal x,y
  501. 6000        sty ytemp
  502. 6010 theplt lda #4      ;screen high
  503. 6020        sta highpt
  504. 6030        lda #>color ;saved color
  505. 6040        sta colhii  ;high byte
  506. 6050        lda #0     ;start mult at 0
  507. 6060        ldx ytemp  ;mult .x times
  508. 6070        beq nomult
  509. 6080 mormlt clc
  510. 6090        adc #40     ;mult. by 40
  511. 6100        bcc nobrk   ;y position
  512. 6110        inc highpt
  513. 6120        inc colhii
  514. 6130 nobrk  dex
  515. 6140        bne mormlt
  516. 6150 nomult clc
  517. 6160        adc xtemp   ;add how many
  518. 6170        bcc notbrk  ;over
  519. 6180        inc highpt
  520. 6190        inc colhii
  521. 6200 notbrk sta lowpnt
  522. 6210        rts
  523. 6220 ;
  524. 6230 revers jsr makexy
  525. 6240        ldy #0
  526. 6250        lda (lowpnt),y ;get charac.
  527. 6260        eor #128  ;invert character
  528. 6270        sta lastch ;save character
  529. 6280        sta (lowpnt),y ;put charac.
  530. 6290        lda highpt
  531. 6300        and #$03   ;prepare high
  532. 6310        ora #$d8   ;byte for color
  533. 6320        sta highpt
  534. 6330        lda #<color ;set low byte
  535. 6340        clc         ;for original
  536. 6350        adc lowpnt  ;screen color
  537. 6360        bcc nocobk  ;saved in mem
  538. 6370        inc colhii
  539. 6380 nocobk sta collow
  540. 6390        lda curcol ;get current col
  541. 6400        ldx oldcol ;use old color
  542. 6410        beq strcol ;no, move on
  543. 6420        lda (collow),y ;yes, get it
  544. 6430 strcol sta (lowpnt),y ;store color
  545. 6440        rts
  546. 6450 ;
  547. 6460 plotxy ldx xptemp
  548. 6470        ldy yptemp
  549. 6480        jmp revers
  550. 6490 ;
  551. 6500 cursor lda oldcol ;save color flag
  552. 6510        pha
  553. 6520        lda #0
  554. 6530        sta oldcol ;plot snag cursr
  555. 6540        jsr plotxy
  556. 6550        pla        ;reset color
  557. 6560        sta oldcol ;flag
  558. 6570        rts
  559. 6580 ;
  560. 6590 ascii  cmp #$20   ;from memory
  561. 6600        bcs one    ;to ascii
  562. 6610 three  clc
  563. 6620        adc #$40
  564. 6630        rts
  565. 6640 one    cmp #$40
  566. 6650        bcs two
  567. 6660        rts
  568. 6670 two    cmp #$60
  569. 6680        bcs three
  570. 6690        clc
  571. 6700        adc #$20
  572. 6710        rts
  573. 6720 ;
  574. 6730 ;the following code either plots a
  575. 6740 ;a single reversed space or
  576. 6750 ;reverses a line if the block is
  577. 6760 ;turned on
  578. 6770 ;
  579. 6780 (NULL)scrn lda xptemp
  580. 6790        cmp xbtemp
  581. 6800        bmi oneblk
  582. 6810        lda yptemp
  583. 6820        cmp ybtemp
  584. 6830        bcs xxblck
  585. 6840 oneblk inc oldcol
  586. 6850        jsr plotxy
  587. 6860        dec oldcol
  588. 6870        lda addmov
  589. 6880        beq subit
  590. 6890        inc xptemp ;increment x pos
  591. 6900        lda xptemp ;is x on block
  592. 6910        cmp xbtemp
  593. 6920        bne outhre
  594. 6930        dec xptemp
  595. 6940        lda yptemp  ;yes, but be
  596. 6950        cmp ybtemp  ;sure y pos is
  597. 6960        bcs xxblck  ;on block too
  598. 6970        inc xptemp
  599. 6980        bne outhre
  600. 6990 subit  dec xptemp
  601. 7000 outhre jmp cursor
  602. 7010 xxblck lda addmov  ;is it an add
  603. 7020        beq notadd  ;0 = sub
  604. 7030        inc xptemp  ;otherwise add
  605. 7040 notadd inc yptemp
  606. 7050        lda xptemp
  607. 7060        sta a
  608. 7070        lda ybtemp
  609. 7080        sta b
  610. 7090 morlin ldx a
  611. 7100        ldy b
  612. 7110        jsr revers
  613. 7120        inc b
  614. 7130        lda b
  615. 7140        cmp yptemp
  616. 7150        bne morlin
  617. 7160        dec yptemp
  618. 7170        lda addmov ;was it a sub
  619. 7180        bne noaddd ;1 = add
  620. 7190        lda xptemp
  621. 7200        cmp xbtemp
  622. 7210        bne nottnd
  623. 7220        dec xptemp
  624. 7230        jmp cursor
  625. 7240 nottnd dec xptemp ;otherwise sub
  626. 7250 noaddd rts
  627. 7260 ;
  628. 7270 xblock lda xpos   ;prepare temps
  629. 7280        sta xptemp ;for a right or
  630. 7290        lda ypos   ;left block move
  631. 7300        sta yptemp
  632. 7310        lda blockx
  633. 7320        sta xbtemp
  634. 7330        lda blocky
  635. 7340        sta ybtemp
  636. 7350        jsr (NULL)scrn ;do the move
  637. 7360        lda xptemp ;get changed
  638. 7370        sta xpos   ;position values
  639. 7380        lda yptemp
  640. 7390        sta ypos
  641. 7400        lda #0
  642. 7410        rts
  643. 7420 ;
  644. 7430 yblock inc flpplt ;prepare temps
  645. 7440        lda xpos   ;for an up or
  646. 7450        sta yptemp ;down block move
  647. 7460        lda ypos
  648. 7470        sta xptemp
  649. 7480        lda blockx
  650. 7490        sta ybtemp
  651. 7500        lda blocky
  652. 7510        sta xbtemp
  653. 7520        jsr (NULL)scrn ;do the move
  654. 7530        lda xptemp ;get changed
  655. 7540        sta ypos   ;position values
  656. 7550        lda yptemp
  657. 7560        sta xpos
  658. 7570        lda #0
  659. 7580        sta flpplt
  660. 7590        rts
  661. 7600 ;
  662. 7610 unblck lda xpos   ;is xpos inside
  663. 7620        cmp blockx ;of block
  664. 7630        bmi noblck ;no, leave here
  665. 7640        lda ypos   ;is ypos inside
  666. 7650        cmp blocky ;of block
  667. 7660        bmi noblck ;no, leave here
  668. 7670        lda blocky
  669. 7680        cmp #$ff   ;is block off
  670. 7690        beq noblck ;yes, leave here
  671. 7700        sta yptemp
  672. 7710        inc oldcol ;reset old color
  673. 7720 ;
  674. 7730 ;this next part finds the end of
  675. 7740 ;each block line so no spaces are
  676. 7750 ;considered as output.  the next
  677. 7760 ;section then un-does the block
  678. 7770 ;and outputs data if the output
  679. 7780 ;flag is non-zero.
  680. 7790 ;
  681. 7800 reduce lda xpos
  682. 7810        sta a
  683. 7820        lda blockx
  684. 7830        sta xptemp
  685. 7840        lda yptemp
  686. 7850        sta b
  687. 7860 morred jsr getxy
  688. 7870        cmp #160   ;is it a space
  689. 7880        bne morex  ;no, end found
  690. 7890        ldx a      ;yes, un-do it
  691. 7900        ldy b
  692. 7910        jsr revers ;unreverse space
  693. 7920        lda a      ;has a line been
  694. 7930        cmp blockx ;reduced
  695. 7940        beq yesx   ;yes, leave here
  696. 7950        dec a      ;no, move left
  697. 7960        jmp morred ;to next column
  698. 7970 ;
  699. 7980 morex  jsr plotxy ;inverse char
  700. 7990        lda output ;disk or printer
  701. 8000        beq notout ;no, skip output
  702. 8010        lda lastch ;get character
  703. 8020        cmp #127
  704. 8030        bcc oksize
  705. 8040        eor #$80
  706. 8050 oksize jsr ascii  ;poke to ascii
  707. 8060        jsr chrout  ;output it
  708. 8070 notout lda xptemp
  709. 8080        cmp a      ;is row erased
  710. 8090        beq yesx
  711. 8100        inc xptemp ;no, add column
  712. 8110        bne morex  ;and (NULL) back
  713. 8120 yesx   lda yptemp
  714. 8130        cmp ypos   ;are rows done
  715. 8140        beq yesy
  716. 8150        lda output
  717. 8160        beq nocr
  718. 8170        lda #13    ;output endoflne
  719. 8180        jsr chrout
  720. 8190 nocr   inc yptemp ;no, add row
  721. 8200        bne reduce ;and (NULL) back
  722. 8210 yesy   dec oldcol ;off color flag
  723. 8220        lda output ;one more cr
  724. 8230        beq noway
  725. 8240        lda #13
  726. 8250        jsr chrout
  727. 8260 noway  lda xpos
  728. 8270        sta xptemp
  729. 8280        jsr plotxy ;turn on cursor
  730. 8290 noblck lda #$ff
  731. 8300        sta blockx ;turn off block
  732. 8310        sta blocky ;with two $ff's
  733. 8320        rts
  734. 8330 ;
  735. 8340 getxy  ldx a
  736. 8350        ldy b
  737. 8360        jsr makexy
  738. 8370        ldy #0
  739. 8380        lda (lowpnt),y
  740. 8390        rts
  741. 8400 ;
  742. 8410 onblck jsr unblck ;un do block
  743. 8420        lda xpos   ;start block at
  744. 8430        sta blockx ;cursor x and y
  745. 8440        lda ypos
  746. 8450        sta blocky
  747. 8460        lda #0
  748. 8470        rts
  749. 8480 ;
  750. 8490 menu1  .asc "   (f) file "
  751. 8500        .asc "  (p) printer  "
  752. 8510        .asc " (f1) exit"
  753. 8520        .byt 0
  754. 8530 menu2  .asc "   enter"
  755. 8540        .asc " file name: "
  756. 8550        .byt 0
  757. 8560 menu3  .asc " append to this"
  758. 8570        .asc " existing file"
  759. 8580        .asc " (y/n)? "
  760. 8590        .byt 0
  761. 8600 menu4  .asc "output device not "
  762. 8610        .asc "present"
  763. 8620        .byt 0
  764. 8630 colors .byt 5,14,15,6,6,0,15,5
  765. 8640        .byt 0,3,6,14,2,6,11,10
  766. 8650 mesbuf .asc " disk: "
  767. 8660 errbuf = *
  768. 8670 *=* + 40
  769. 8680 color = *
  770. 8690 *=* + 1024
  771. 8700 menu = *
  772. 8710 *=* + 240
  773. 8720 fname = *
  774. 8730 *=* + 20
  775. 8740 stktmp = *
  776. 8750 *=*+1
  777. 8760 tmpbyt = *
  778. 8770 *=*+1
  779.